package com.epam.training.domain;

import java.io.Serializable;

import javax.persistence.*;

import java.math.BigDecimal;
import java.util.Date;

/**
 * The persistent class for the paymant database table.
 * 
 */
@Entity
@Table(name = "paymant")
@NamedQuery(name = "Paymant.findAll", query = "SELECT p FROM Paymant p")
public class Paymant implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "PAYMANT_PAYMANTID_GENERATOR", sequenceName = "PAYMANT_ID_SEQ", initialValue = 1, allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PAYMANT_PAYMANTID_GENERATOR")
	@Column(name = "paymant_id", insertable = false, updatable = false, unique = true, nullable = false)
	private Integer paymantId;

	@Column(precision = 131089)
	private BigDecimal paid;

	@Temporal(TemporalType.DATE)
	@Column(name = "paymant_date")
	private Date paymantDate;

//	// bi-directional many-to-one association to Bookingitem
//	@OneToMany(mappedBy = "paymant")
//	private List<BookingItem> bookingItems;

	// bi-directional many-to-one association to Bonus
	@ManyToOne
	@JoinColumn(name = "bonus_id")
	private Bonus bonus;

	// bi-directional many-to-one association to Penalty
	@ManyToOne
	@JoinColumn(name = "penalty_id")
	private Penalty penalty;

	public Paymant() {
	}

	public Integer getPaymantId() {
		return this.paymantId;
	}

	public void setPaymantId(Integer paymantId) {
		this.paymantId = paymantId;
	}

	public BigDecimal getPaid() {
		return this.paid;
	}

	public void setPaid(BigDecimal paid) {
		this.paid = paid;
	}

	public Date getPaymantDate() {
		return this.paymantDate;
	}

	public void setPaymantDate(Date paymantDate) {
		this.paymantDate = paymantDate;
	}

	public Bonus getBonus() {
		return this.bonus;
	}

	public void setBonus(Bonus bonus) {
		this.bonus = bonus;
	}

	public Penalty getPenalty() {
		return this.penalty;
	}

	public void setPenalty(Penalty penalty) {
		this.penalty = penalty;
	}

//	public List<BookingItem> getBookingItems() {
//		return this.bookingItems;
//	}
//
//	public void setBookingitems(List<BookingItem> bookingitems) {
//		this.bookingItems = bookingitems;
//	}
//
//	public BookingItem addBookingitem(BookingItem bookingitem) {
//		getBookingItems().add(bookingitem);
//		bookingitem.setPaymant(this);
//
//		return bookingitem;
//	}
//
//	public BookingItem removeBookingitem(BookingItem bookingItem) {
//		getBookingItems().remove(bookingItem);
//		bookingItem.setPaymant(null);
//
//		return bookingItem;
//	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((bonus == null) ? 0 : bonus.hashCode());
//		result = prime * result
//				+ ((bookingItems == null) ? 0 : bookingItems.hashCode());
		result = prime * result + ((paid == null) ? 0 : paid.hashCode());
		result = prime * result
				+ ((paymantDate == null) ? 0 : paymantDate.hashCode());
		result = prime * result
				+ ((paymantId == null) ? 0 : paymantId.hashCode());
		result = prime * result + ((penalty == null) ? 0 : penalty.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Paymant other = (Paymant) obj;
		if (bonus == null) {
			if (other.bonus != null)
				return false;
		} else if (!bonus.equals(other.bonus))
			return false;
//		if (bookingItems == null) {
//			if (other.bookingItems != null)
//				return false;
//		} else if (!bookingItems.equals(other.bookingItems))
//			return false;
		if (paid == null) {
			if (other.paid != null)
				return false;
		} else if (!paid.equals(other.paid))
			return false;
		if (paymantDate == null) {
			if (other.paymantDate != null)
				return false;
		} else if (!paymantDate.equals(other.paymantDate))
			return false;
		if (paymantId == null) {
			if (other.paymantId != null)
				return false;
		} else if (!paymantId.equals(other.paymantId))
			return false;
		if (penalty == null) {
			if (other.penalty != null)
				return false;
		} else if (!penalty.equals(other.penalty))
			return false;
		return true;
	}

}
